/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ImprimirPlanillaLlamado.java
 *
 * Created on 21-ene-2013, 15:08:52
 */
package gui;

import com.sun.awt.AWTUtilities;
import controladores.ControladorPrincipal;
import io.Llamado;
import io.Nino_Adolescente;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Shape;
import java.awt.geom.RoundRectangle2D;
import java.awt.print.PageFormat;
import java.awt.print.Paper;
import java.awt.print.Printable;
import java.awt.print.PrinterJob;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import utilidades.JFrameConFondo;

/**
 *
 * @author NiCo
 */
public class ImprimirPlanillaLlamado extends JFrameConFondo implements Printable {

    private List<Llamado> dia = null;
    private ArrayList<List<Llamado>> dias = null;
    private ArrayList<List<Llamado>> diasAux = null;
    private Image icono = new ImageIcon(getClass().getResource("/imagenes/logo.png")).getImage();
    private int cantidad = 0;
    private ArrayList<Integer> estadistica = null;
    private ArrayList<ArrayList<Integer>> estDias = null;

    /** Creates new form ImprimirPlanillaLlamado */
    public ImprimirPlanillaLlamado() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        btnCerrar = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        dtpFecha1 = new com.toedter.calendar.JDateChooser();
        rbtnFecha = new javax.swing.JRadioButton();
        rbtnPeriodo = new javax.swing.JRadioButton();
        dtpFecha2 = new com.toedter.calendar.JDateChooser();
        dtpFecha3 = new com.toedter.calendar.JDateChooser();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        btnCerrar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/cerrar-normal.png"))); // NOI18N
        btnCerrar.setBorder(null);
        btnCerrar.setBorderPainted(false);
        btnCerrar.setFocusPainted(false);
        btnCerrar.setName("btnCerrar"); // NOI18N
        btnCerrar.setOpaque(false);
        btnCerrar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                btnCerrarMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                btnCerrarMouseExited(evt);
            }
            public void mousePressed(java.awt.event.MouseEvent evt) {
                btnCerrarMousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                btnCerrarMouseReleased(evt);
            }
        });
        btnCerrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCerrarActionPerformed(evt);
            }
        });

        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/titulo-planilla-diaria.png"))); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/imprimir.png"))); // NOI18N
        jButton1.setBorderPainted(false);
        jButton1.setFocusPainted(false);
        jButton1.setName("jButton1"); // NOI18N
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        dtpFecha1.setDateFormatString("dd/MM/yyyy");
        dtpFecha1.setEnabled(false);
        dtpFecha1.setFont(new java.awt.Font("Tahoma 12", 0, 12));
        dtpFecha1.setName("dtpFecha1"); // NOI18N

        buttonGroup1.add(rbtnFecha);
        rbtnFecha.setFont(new java.awt.Font("Tahoma 12", 1, 12)); // NOI18N
        rbtnFecha.setText("Fecha");
        rbtnFecha.setName("rbtnFecha"); // NOI18N
        rbtnFecha.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rbtnFechaActionPerformed(evt);
            }
        });

        buttonGroup1.add(rbtnPeriodo);
        rbtnPeriodo.setFont(new java.awt.Font("Tahoma 12", 1, 12)); // NOI18N
        rbtnPeriodo.setText("Período de fechas");
        rbtnPeriodo.setName("rbtnPeriodo"); // NOI18N
        rbtnPeriodo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rbtnPeriodoActionPerformed(evt);
            }
        });

        dtpFecha2.setDateFormatString("dd/MM/yyyy");
        dtpFecha2.setEnabled(false);
        dtpFecha2.setFont(new java.awt.Font("Tahoma 12", 0, 12));
        dtpFecha2.setName("dtpFecha2"); // NOI18N

        dtpFecha3.setDateFormatString("dd/MM/yyyy");
        dtpFecha3.setEnabled(false);
        dtpFecha3.setFont(new java.awt.Font("Tahoma 12", 0, 12));
        dtpFecha3.setName("dtpFecha3"); // NOI18N

        jLabel3.setFont(new java.awt.Font("Tahoma 12", 0, 12));
        jLabel3.setText("Desde");
        jLabel3.setName("jLabel3"); // NOI18N

        jLabel4.setFont(new java.awt.Font("Tahoma 12", 0, 12));
        jLabel4.setText("Hasta");
        jLabel4.setName("jLabel4"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(306, Short.MAX_VALUE)
                .addComponent(btnCerrar)
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addGap(71, 71, 71)
                .addComponent(jLabel2)
                .addContainerGap(89, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(rbtnPeriodo)
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel4)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(dtpFecha3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel3)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(dtpFecha2, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(rbtnFecha)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(dtpFecha1, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(39, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addGap(98, 98, 98)
                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(106, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnCerrar)
                    .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 30, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(rbtnFecha)
                    .addComponent(dtpFecha1, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(rbtnPeriodo)
                        .addComponent(jLabel3))
                    .addComponent(dtpFecha2, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel4)
                    .addComponent(dtpFecha3, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnCerrarMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnCerrarMouseEntered

        btnCerrar.setIcon(new ImageIcon(getClass().getResource("/imagenes/cerrar-activo.png")));     }//GEN-LAST:event_btnCerrarMouseEntered

    private void btnCerrarMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnCerrarMouseExited

        btnCerrar.setIcon(new ImageIcon(getClass().getResource("/imagenes/cerrar-normal.png")));     }//GEN-LAST:event_btnCerrarMouseExited

    private void btnCerrarMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnCerrarMousePressed

        btnCerrar.setIcon(new ImageIcon(getClass().getResource("/imagenes/cerrar-click.png")));     }//GEN-LAST:event_btnCerrarMousePressed

    private void btnCerrarMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnCerrarMouseReleased

        btnCerrar.setIcon(new ImageIcon(getClass().getResource("/imagenes/cerrar-normal.png")));     }//GEN-LAST:event_btnCerrarMouseReleased

    private void btnCerrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCerrarActionPerformed
        this.dispose();
    }//GEN-LAST:event_btnCerrarActionPerformed

    private void rbtnFechaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbtnFechaActionPerformed
        dtpFecha1.setEnabled(true);
        dtpFecha1.setDate(null);
        dtpFecha2.setEnabled(false);
        dtpFecha2.setDate(null);
        dtpFecha3.setEnabled(false);
        dtpFecha3.setDate(null);
    }//GEN-LAST:event_rbtnFechaActionPerformed

    private void rbtnPeriodoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbtnPeriodoActionPerformed
        dtpFecha1.setEnabled(false);
        dtpFecha1.setDate(null);
        dtpFecha2.setEnabled(true);
        dtpFecha2.setDate(null);
        dtpFecha3.setEnabled(true);
        dtpFecha3.setDate(null);
    }//GEN-LAST:event_rbtnPeriodoActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        if (rbtnFecha.isSelected() && dtpFecha1.getDate() != null) {
            dia = ControladorPrincipal.getInstance().getControladorCasos().llamados(dtpFecha1.getDate());
            if (!dia.isEmpty()) {
                double aux = ((double) dia.size() / 26.0) - 1;
                int aux1 = (int) aux;
                double dec = aux - aux1;
                if (dec > 0) {
                    cantidad = aux1 + 1;
                }
                if (cantidad < 0) {
                    cantidad = 0;
                }
                estadistica = ControladorPrincipal.getInstance().getControladorCasos().estadisticas(dia);
                PrinterJob job = PrinterJob.getPrinterJob();
                Paper hoja = new Paper();
                hoja.setImageableArea(0, 0, 595, 841);
                hoja.setSize(595, 841);
                job.setPrintable(this);
                try {
                    // Diálogo para elegir el formato de impresión
                    PageFormat pageFormat = new PageFormat();
                    pageFormat.setPaper(hoja);
                    //pageFormat = job.pageDialog(pageFormat);
                    if (job.printDialog()) {
                        job.print();
                    }
                } catch (Exception e) {
                }
            } else {
                MensajesInfo p1 = new MensajesInfo('n', "NoLlamados");
                p1.setLocationRelativeTo(null);
                p1.setIconImage(icono);
                p1.setVisible(true);
                Shape shape = new RoundRectangle2D.Float(0, 0, p1.getWidth(), p1.getHeight(), 30, 30);
                AWTUtilities.setWindowShape(p1, shape);
            }
        } else {
            if (rbtnPeriodo.isSelected() && dtpFecha2.getDate() != null && dtpFecha3.getDate() != null) {
                if (dtpFecha2.getDate().before(dtpFecha3.getDate())) {
                    dias = new ArrayList<List<Llamado>>();
                    estDias = new ArrayList<ArrayList<Integer>>();
                    Date aux = dtpFecha2.getDate();
                    Calendar fecha = Calendar.getInstance();
                    fecha.setTime(aux);
                    while (aux.compareTo(dtpFecha3.getDate()) <= 0) {
                        dia = ControladorPrincipal.getInstance().getControladorCasos().llamados(aux);
                        if (!dia.isEmpty()) {
                            dias.add(dia);
                        }
                        fecha.add(Calendar.DATE, 1);
                        aux = fecha.getTime();
                    }
                    if (!dias.isEmpty()) {
                        diasAux = new ArrayList<List<Llamado>>();
                        Iterator<List<Llamado>> it = dias.iterator();
                        cantidad = -1;
                        while (it.hasNext()) {
                            cantidad++;
                            List<Llamado> lista = it.next();
                            estDias.add(ControladorPrincipal.getInstance().getControladorCasos().estadisticas(lista));
                            diasAux.add(lista);
                            double aux2 = ((double) lista.size() / 26.0) - 1;
                            int aux1 = (int) aux2;
                            double dec = aux2 - aux1;
                            if (dec > 0) {
                                cantidad = cantidad + aux1 + 1;
                            }
                            if ((cantidad - (diasAux.size() - 1)) != 0) {
                                List<Llamado> lisAux = diasAux.get(diasAux.size() - 1);
                                diasAux.set(diasAux.size() - 1, lisAux.subList(0, 26));
                            }
                            for (int i = 1; i <= cantidad - (diasAux.size() - 1); i++) {
                                if ((51 + (26 * i)) < lista.size() - 1) {
                                    diasAux.add(lista.subList(26 * i, 52 + (26 * i)));
                                    estDias.add(ControladorPrincipal.getInstance().getControladorCasos().estadisticas(lista));
                                } else {
                                    diasAux.add(lista.subList(26 * i, lista.size()));
                                    estDias.add(ControladorPrincipal.getInstance().getControladorCasos().estadisticas(lista));
                                }
                            }
                        }

                        PrinterJob job = PrinterJob.getPrinterJob();
                        Paper hoja = new Paper();
                        hoja.setImageableArea(0, 0, 595, 841);
                        hoja.setSize(595, 841);
                        job.setPrintable(this);
                        try {
                            // Diálogo para elegir el formato de impresión
                            PageFormat pageFormat = new PageFormat();
                            pageFormat.setPaper(hoja);
                            //pageFormat = job.pageDialog(pageFormat);
                            if (job.printDialog()) {
                                job.print();
                            }
                        } catch (Exception e) {
                        }
                    } else {
                        MensajesInfo p1 = new MensajesInfo('n', "NoLlamadosP");
                        p1.setLocationRelativeTo(null);
                        p1.setIconImage(icono);
                        p1.setVisible(true);
                        Shape shape = new RoundRectangle2D.Float(0, 0, p1.getWidth(), p1.getHeight(), 30, 30);
                        AWTUtilities.setWindowShape(p1, shape);
                    }
                } else {
                    MensajesInfo p1 = new MensajesInfo('e', "Fechas");
                    p1.setLocationRelativeTo(null);
                    p1.setIconImage(icono);
                    p1.setVisible(true);
                    Shape shape = new RoundRectangle2D.Float(0, 0, p1.getWidth(), p1.getHeight(), 30, 30);
                    AWTUtilities.setWindowShape(p1, shape);
                }
            } else {
                MensajesInfo p1 = new MensajesInfo('e', "CamposVacios");
                p1.setLocationRelativeTo(null);
                p1.setIconImage(icono);
                p1.setVisible(true);
                Shape shape = new RoundRectangle2D.Float(0, 0, p1.getWidth(), p1.getHeight(), 30, 30);
                AWTUtilities.setWindowShape(p1, shape);
            }
        }
    }//GEN-LAST:event_jButton1ActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCerrar;
    private javax.swing.ButtonGroup buttonGroup1;
    private com.toedter.calendar.JDateChooser dtpFecha1;
    private com.toedter.calendar.JDateChooser dtpFecha2;
    private com.toedter.calendar.JDateChooser dtpFecha3;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JRadioButton rbtnFecha;
    private javax.swing.JRadioButton rbtnPeriodo;
    // End of variables declaration//GEN-END:variables

    @Override
    public int print(Graphics g, PageFormat f, int pageIndex) {
        SimpleDateFormat sdf = new java.text.SimpleDateFormat("dd/MM/yyyy");
        SimpleDateFormat sdf1 = new java.text.SimpleDateFormat("HH:mm");
        if (pageIndex >= 0 && pageIndex <= cantidad) {
            try {
                // Imprime "Hola mundo" en la primera pagina, en la posicion 100,100
                Image img = ImageIO.read(new File("src/imagenes/ficha-llamados.png").toURI().toURL());
                g.drawImage(img, 52, 0, 491, 801, null);
            } catch (Exception ex) {
            }
            if (rbtnFecha.isSelected()) {
                g.setFont(new Font("Tahoma", Font.BOLD, 16));
                g.drawString(sdf.format(dtpFecha1.getDate()), 112, 145);
                g.setFont(new Font("Tahoma", Font.PLAIN, 10));
                int j = 0;
                for (int i = pageIndex * 26; i < dia.size(); i++) {
                    if (j <= 25) {
                        Llamado llamado = dia.get(i);
                        g.drawString(llamado.getOperador().toString(), 54, 192 + (j * 15));
                        g.drawString(sdf1.format(llamado.getHora()), 130, 192 + (j * 15));
                        if (llamado.getCaso() != null) {
                            g.drawString(llamado.getCaso().getNumeroCaso().toString(), 168, 192 + (j * 15));
                            Nino_Adolescente nino = llamado.getCaso().getNino_adolescente();
                            int indiceCaso = nino.getCasos().indexOf(llamado.getCaso());
                            if (indiceCaso > 0) {
                                g.drawString(nino.getCasos().get(indiceCaso - 1).getNumeroCaso().toString(), 217, 192 + (j * 15));
                            }
                        }
                        if (llamado.getActualizacion() != null) {
                            g.drawString(llamado.getActualizacion().getCaso().getNumeroCaso().toString(), 217, 192 + (j * 15));
                            g.drawString("SI", 274, 192 + (j * 15));
                        } else {
                            g.drawString("NO", 274, 192 + (j * 15));
                        }
                        if (llamado.isInfo_asesoramiento()) {
                            g.drawString("SI", 337, 192 + (j * 15));
                        } else {
                            g.drawString("NO", 337, 192 + (j * 15));
                        }
                        if (llamado.isInstitucion()) {
                            g.drawString("SI", 392, 192 + (j * 15));
                        } else {
                            g.drawString("NO", 392, 192 + (j * 15));
                        }
                        if (llamado.isParticular()) {
                            g.drawString("SI", 447, 192 + (j * 15));
                        } else {
                            g.drawString("NO", 447, 192 + (j * 15));
                        }
                        if (llamado.isBroma_otros()) {
                            g.drawString("SI", 508, 192 + (j * 15));
                        } else {
                            g.drawString("NO", 508, 192 + (j * 15));
                        }
                        j++;
                    } else {
                        break;
                    }
                }
                for (int i = 0; i < estadistica.size(); i++) {
                    g.drawString(String.valueOf(estadistica.get(i)), 376, 608 + (i * 15));
                }
            } else {
                if (rbtnPeriodo.isSelected()) {
                    List<Llamado> lista = diasAux.get(pageIndex);
                    g.setFont(new Font("Tahoma", Font.BOLD, 16));
                    g.drawString(sdf.format(lista.get(0).getFecha()), 112, 145);
                    g.setFont(new Font("Tahoma", Font.PLAIN, 10));
                    for (int i = 0; i < lista.size(); i++) {
                        Llamado llamado = lista.get(i);
                        g.drawString(llamado.getOperador().toString(), 54, 192 + (i * 15));
                        g.drawString(sdf1.format(llamado.getHora()), 130, 192 + (i * 15));
                        if (llamado.getCaso() != null) {
                            g.drawString(llamado.getCaso().getNumeroCaso().toString(), 168, 192 + (i * 15));
                            Nino_Adolescente nino = llamado.getCaso().getNino_adolescente();
                            int indiceCaso = nino.getCasos().indexOf(llamado.getCaso());
                            if (indiceCaso > 0) {
                                g.drawString(nino.getCasos().get(indiceCaso - 1).getNumeroCaso().toString(), 217, 192 + (i * 15));
                            }
                        }
                        if (llamado.getActualizacion() != null) {
                            g.drawString(llamado.getActualizacion().getCaso().getNumeroCaso().toString(), 217, 192 + (i * 15));
                            g.drawString("SI", 274, 192 + (i * 15));
                        } else {
                            g.drawString("NO", 274, 192 + (i * 15));
                        }
                        if (llamado.isInfo_asesoramiento()) {
                            g.drawString("SI", 337, 192 + (i * 15));
                        } else {
                            g.drawString("NO", 337, 192 + (i * 15));
                        }
                        if (llamado.isInstitucion()) {
                            g.drawString("SI", 392, 192 + (i * 15));
                        } else {
                            g.drawString("NO", 392, 192 + (i * 15));
                        }
                        if (llamado.isParticular()) {
                            g.drawString("SI", 447, 192 + (i * 15));
                        } else {
                            g.drawString("NO", 447, 192 + (i * 15));
                        }
                        if (llamado.isBroma_otros()) {
                            g.drawString("SI", 508, 192 + (i * 15));
                        } else {
                            g.drawString("NO", 508, 192 + (i * 15));
                        }
                    }
                    estadistica = estDias.get(pageIndex);
                    for (int i = 0; i < estadistica.size(); i++) {
                        g.drawString(String.valueOf(estadistica.get(i)), 376, 608 + (i * 15));
                    }
                }
            }

            return PAGE_EXISTS;
        } else {
            return NO_SUCH_PAGE;
        }
    }
}
